package models

type User struct {
	UID       string `gorm:"column:uid;comment:'用戶uid';primaryKey" json:"uid" form:"uid"`
	Username  string `gorm:"column:username;comment:'用户名';size:128;uniqueIndex:uk_username;not null;unique"  json:"username"  form:"username"`
	Password  string `gorm:"column:password;comment:'用户密码';size:128" json:"password"  form:"password"`
	Phone     string `gorm:"column:phone;comment:'手机号码';size:11" json:"phone" form:"phone"`
	Email     string `gorm:"column:email;comment:'邮箱';size:128" json:"email" form:"email"`
	Avatar    string `gorm:"column:avatar;default:https://img1.baidu.com/it/u=2206814125,3628191178&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500;comment:'用户头像';size:128" json:"avatar" form:"avatar"`
	Status    uint   `gorm:"type:tinyint(1);default:1;comment:'用户状态(正常/禁用, 默认正常)'" json:"status" form:"status"`
	DeptId    uint   `gorm:"default:1;comment:'部门id外键'" json:"dept_id"`
	Dept      Dept   `gorm:"foreignkey:DeptId" json:"dept"`
	Roles     []Role `gorm:"many2many:user_roles" json:"roles"`
	CreatedAt string `gorm:"column:created_at;comment:'创建时间'" json:"created_at"`
	UpdatedAt string `gorm:"column:updated_at;comment:'更新时间'" json:"updated_at"`
	DeletedAt string `gorm:"column:deleted_at;comment:'删除时间'" json:"deleted_at"`
}

type UpUser struct {
	UID      string `json:"uid" form:"uid" binding:"required"`
	Username string `json:"username" form:"username" binding:"required"`
	Password string `json:"password" form:"password"`
	Phone    string `json:"phone" form:"phone"`
	Email    string `json:"email"  form:"email"`
	Avatar   string `json:"avatar" form:"avatar"`
	Roles    []uint `json:"roles" form:"roles"`
	Status   uint   `json:"status"  form:"status"`
}

type RespUser struct {
	ID        uint   `json:"id"`
	UID       string `json:"uid"`
	Username  string `json:"username"`
	Avatar    string `json:"avatar"`
	Status    uint   `json:"status"`
	CreatedAt string `json:"createdAt"`
	UpdatedAt string `json:"updatedAt"`
	Email     string `json:"email"`
	Phone     string `json:"phone"`
	Token     string `json:"token"`
}

type UserList struct {
	Items []*User `json:"items"`
	Total int64   `json:"total"`
}
